package com.bit.transaction.controller;

import com.bit.transaction.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/trans")
public class TransactionController {
    @Autowired
    private UserService userService;

    @Transactional
    @RequestMapping("/registry1")
    public String registry1(String name, String password){
        userService.registryUser(name,password);
        log.info("用户插入数据成功");
        int a = 1/0;
        return "注册用户成功";
    }

    @Transactional
    @RequestMapping("/registry2")
    public String registry2(String name, String password){
        userService.registryUser(name,password);
        log.info("用户插入数据成功");
        try{
            int a = 1/0;
        }catch(Exception e){
            e.printStackTrace();
        }
        return "注册用户成功";
    }
}
